<?php
define ( 'IN_templates', "admin" );
include (dirname(__FILE__)."/../includes/init.php");//全局变量

//登录的管理员id
$input_adminid=trim(isset($_SESSION['user_id'])?$fun->authcode($_SESSION['user_id'], 'DECODE', $pwdconstant,$expiry =$lifeTime):"");
if(empty($input_adminid)){
	@$str="<html><title>系统提示</title>";
	$str .="<link href='../favicon.ico' type='image/x-icon' rel='icon' />";
	$str .="<link href='../favicon.ico' type='image/x-icon' rel='shortcut icon'/>";
	$str .="</head><body>";
	$str .= "<center>";
	$str .= "  <div id=\"msg\" style=\"font-size:18px;width:500px; padding:15px; border: 10px solid #66B1DD; background-color: #FFF; margin:150px auto;\">\n";
	$str .= "  <div style=\"margin:30px auto;text-align:center;font-size:18px;font-weight:bold; color:#666;\">登录超时,无法访问,请重新登录</div>\n";
	$str .= '    <script language="javascript" type="text/javascript">parent.window.location.href="index.php";</script>';
	$str .= "    <p style=\"text-align:center;\"><a style=\"font-size:14px;color:#333;font-weight:bold; text-decoration:underline;\" href=\"javascript:parent.window.location.href='index.php';\">如果您的浏览器没有自动跳转,请点击这里...</a></p>\n";
	$str .= "  </div>\n";
	$str .= "</center>";
	exit($str."</body>\n</html>");
}else{
	$admin_user=$db->get_one("SELECT * FROM `".$tbprefix."admin` WHERE `adminid`='{$input_adminid}' AND `state`='1' AND `is_valid`='1' AND 1");
	//对管理员操作权限
	$adminPower=isset($admin_user['permission'])?$admin_user['permission']:1;
	if(empty($admin_user['adminid'])){
		//做清除session处理 防止死循环
		unset($_SESSION['user_id']);//清除登录的用户id
		unset($_SESSION['act_url']); //清除超链接
		
		$up_url=isset($up_url)?$up_url:"";
		@$str="<html><title>系统提示</title>";
		$str .="<link href='../favicon.ico' type='image/x-icon' rel='icon' />";
		$str .="<link href='../favicon.ico' type='image/x-icon' rel='shortcut icon'/>";
		$str .="</head><body>";
		$str .= "<center>";
		$str .= "  <div id=\"msg\" style=\"font-size:18px;width:500px; padding:15px; border: 10px solid #66B1DD; background-color: #FFF; margin:150px auto;\">\n";
		$str .= "  <div style=\"margin:30px auto;text-align:center;font-size:18px;font-weight:bold; color:#666;\">管理员不存在,无法访问,请重新登录</div>\n";
		$str .= '    <script language="javascript" type="text/javascript">parent.window.location.href="index.php";</script>';
		$str .= "    <p style=\"text-align:center;\"><a style=\"font-size:14px;color:#333;font-weight:bold; text-decoration:underline;\" href=\"javascript:parent.window.location.href='index.php';\">如果您的浏览器没有自动跳转,请点击这里...</a></p>\n";
		$str .= "  </div>\n";
		$str .= "</center>";
		exit($str."</body>\n</html>");
	}
	
}

?>